//vue 如何追踪变化

function defineReactive(data,key,val){

  Object.defineProperty(data,key,{
    enumerable:true,
    configurable:true,
    get(){
      return val
    },
    set(newVal){
      if(val===newVal){
        return 
      }
      return val
    }
  })

}


class Observer{
  constructor(value){
    this.value=value
    if(!Array.isArray(value)){
      this.walk(value)
    }
  }

  walk(obj){
    const keys=Object.keys(obj)
    for(let i=0;i<keys.length;i++){
      defineReactive(obj,keys[i],obj[keys[i]])
    }

  }
}